package net.halflite.mzkr.form.regist;

import java.io.Serializable;

import net.halflite.mzkr.entity.RegistedUser;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.seasar.framework.container.annotation.tiger.Component;
import org.seasar.framework.container.annotation.tiger.InstanceType;
import org.seasar.struts.annotation.Arg;
import org.seasar.struts.annotation.Mask;
import org.seasar.struts.annotation.Maxlength;
import org.seasar.struts.annotation.Minlength;
import org.seasar.struts.annotation.Msg;
import org.seasar.struts.annotation.Required;
import org.seasar.struts.annotation.Validwhen;

/** パスワード再発行用ActionForm */
@Component(instance = InstanceType.SESSION)
public class ReissuePasswordForm implements Serializable {

	private static final long serialVersionUID = 1L;

	/** ハッシュキー */
	@Mask(mask = "[0-9a-f]{32}", msg = @Msg(key = "errors.invalid.hash"),
			target = "index")
	public String hash;

	/** パスワード */
	@Required(arg0 = @Arg(key = "パスワード", resource = false),
			target = "post")
	@Minlength(minlength = RegistedUser.MIN_PASSWORD_LENGTH, 
			arg0 = @Arg(key = "パスワード", resource = false),
			target = "post")
	@Maxlength(maxlength = RegistedUser.MAX_PASSWORD_LENGTH, 
			arg0 = @Arg(key = "パスワード", resource = false),
			target = "post")
	public String password;

	/** パスワード確認 */
	@Validwhen(test = "((password == null) or (*this* == password))",
			msg = @Msg(key = "errors.confirm.not.equal"),
			arg0 = @Arg(key = "パスワード", resource = false),
			target = "post")
	public String confirm;
	
	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}
}
